{{include file ="admin/header.tpl"}} {{include file
="admin/navibar.tpl"}} {{include file ="admin/sidebar.tpl"}}

<link rel="stylesheet" type="text/css"
	href="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript"
	src="{{$smarty.const.WEBSITE_URL}}/public/assets/lib/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<style>
#addwin {
	margin: -400px 0 0 -280px;
	/* PLAY THE WITH THE VALUES TO SEE GET THE DESIRED EFFECT */
}
</style>
<script type="text/javascript">


 

	function addWindow(){
		modelshow();
	}

	 function modelshow(){ 
		 $('#addwin').modal('show');
	 }
	 function modelhide(){
		 $('#addwin').modal('hide');
	 }
	 
	 
	function newUser(){
		$("#form").form('clear');
		modelshow();
	}
	function editUser(){
		var select = getSelectItem();
		if(select == null || select.length == 0 ){
			$.messager.alert('错误','请选择要修改的记录!');
			return;
		}

		if(select[0].uiFlag == 1){
			$.messager.alert('提示','该记录不可编辑!');
			return;
		}
		$("#form").form('clear');
		modelshow();
		$("#form").form('load',select[0]);
	
	}
	function removeUser(){
		$.messager.confirm('删除确定','确定要删除当前选择的记录!',function(r){
		    if (r){
		    	var select = getSelectItem();
				if(select == null || select.length == 0 ){
					$.messager.alert('错误','请选择要删除的记录!');
					return;
				}
				$.ajax({  
		            type: "POST",  
		            dataType: "json",  
		            url: '{{$smarty.const.WEBSITE_URL}}admin/systemparam/delete',
		            data: { id: select[0].id },  
		            success: function (data) {  
		             	$('#grid').datagrid('reload'); 
		            },  
		            error: function () {  
		            }  
		        });  
		    }
		});
		
	}


	function submitStatusChange(){
		  if(!$('#form').form('validate')){
		        return;
		     }
	    $.post(
				'{{$smarty.const.WEBSITE_URL}}admin/systemparam/addOrModify',
				$('#form').serialize(),
				function(data){ 
					modelhide();
			    	$('#grid').datagrid('reload'); 
				},
				"json"
	    );
	}
	  
	function win_close(){
		modelhide();
	}


	function getSelectItem(){
		var select  = $("#grid").datagrid('getSelections');
		if(select == null || select.length == 0 ){
			return null;
		}
		return select;
	}


	function editFlagFormatter(value,index,row){
		if(value == 0){
			return "可编辑";
		}
		if(value==1){
			return "不可编辑";
		}
		return value;
	}

// 	 var roles;
// 		function loadRoles(){
// 			 if(roles != null){
// 				 document.getElementById("role_id").innerHTML=createOptions(roles);  
// 				 return;
// 			 }
// 			 $.ajax({
// 		            type: "POST",
// 		            url: '{{$web_root}}adminuser/getallrole',
// 		            success:function(data){
// 		            	 var data = $.parseJSON(data);
// 		            	 roles = data;
// 			    		 document.getElementById("role_id").innerHTML=createOptions(data);  
// 				    },
// 		            error: function () {
// 		            }
// 		        });

			
// 		 }
// 		  function createOptions(data){
// 			 var name = "";
// 			 for(var i=0;data!=null&&i<data.length;i++){  
// 			   var cudata=data[i];  
// 			   name=name+"<option value='"+cudata.role_id+"'>"+cudata.role_name+"</option>"  
// 			 }  
// 			 return name;
// 		 }
		 
</script>

<div class="content">
	<div class="header">
		<div class="stats">
			<p class="stat">
				<!--span class="number"></span-->
			</p>
		</div>

		<h1 class="page-title">后台管理员管理</h1>
	</div>

	<!-- <ul class="breadcrumb">
            <li><a href="{{$smarty.const.WEBSITE_URL}}admin/user">管理列表</a> <span class="divider">/</span></li>  
			 <a title= "移除快捷菜单" href="#"><li class="active"><i class="icon-minus" method="del" url="#"></i></li></a>
	         <a title= "加入快捷菜单" href="#"><li class="active"><i class="icon-plus" method="add" url="#"></i></li></a>
        </ul> -->
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="bb-alert alert alert-info" style="display: none;">
				<span>操作成功</span>
			</div>
			<!--- START 以上内容不需更改，保证该TPL页内的标签匹配即可 --->


			<table id="grid"
				data-options="url:'{{$smarty.const.WEBSITE_URL}}admin/systemparam/getpage',fitColumns:true,singleSelect:true"
				class="easyui-datagrid" style="width: auto; height: 350px"
				toolbar="#toolbar" iconCls="icons-save" pagination="true"
				rownumbers="true">
				<thead>
					<tr>
						<th data-options="field:'id',width:100,checkbox:true"></th>
						<th data-options="field:'name',width:100">参数名</th>
						<th data-options="field:'value',width:100">参数值</th>
						<th data-options="field:'uiFlag',width:100,formatter:editFlagFormatter">是否可编辑</th>
						 
						<th data-options="field:'paramdesc',width:100">描述</th>
					
					</tr>
				</thead>
			</table>

			<div id="toolbar">
				<a   class="easyui-linkbutton" iconCls="icons-add"
					plain="true" onclick="newUser()">添加</a> <a  
					class="easyui-linkbutton" iconCls="icons-edit" plain="true"
					onclick="editUser()">修改</a> <a  
					class="easyui-linkbutton" iconCls="icons-remove" plain="true"
					onclick="removeUser()">删除</a>
			</div>



			<div id="addwin" class="modal hide fade">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h5>用户信息管理</h5>
				</div>
				<div class="modal-body">
					<form id="form" method="post" class="form-horizontal" >
						<div class="control-group" hidden="true">
							<input type="text" name="id" hidden="true">
						</div>
						<div class="control-group">
							<label class="control-label" for="Text input">参数名:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="name" name="name"
									placeholder="请输入名称">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="inputPassword">参数值:</label>
							<div class="controls">
								<input type="text" class="easyui-validatebox"
									data-options="required:true" id="value" name="value"
									 >
							</div>
						</div>

				 

						<div class="control-group">
							<label class="control-label" for="Text input">是否可以编辑:</label>
							<div class="controls">
								<select id="uiFlag" name="uiFlag">
									<option value="0">可编辑</option>
									<option value="1">不可编辑</option>
								</select>
							</div>
						</div>

					 
						<div class="control-group">
							<label class="control-label" for="Text input">参数描述:</label>
							<div class="controls">
								<textarea rows="2" id="paramdesc" name="paramdesc"></textarea>
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer" id="div_view">
					<button type="button" style="width: 100px;" class="btn btn-primary"
						onclick="submitStatusChange()">提交</button>
					<button type="button" onclick="win_close()" style="width: 100px;"
						class="btn">取消</button>

				</div>
			</div>

			<!--- END 以下内容不需更改，请保证该TPL页内的标签匹配即可 --->
			{{include file="admin/footer.tpl" }}